package com.hgkj.system.service.impl;

import com.hgkj.system.domain.SysDictData;
import com.hgkj.system.service.SysDictDataService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SysDictDataServiceImpl implements SysDictDataService {

    /**
     * 获取数据字典数据
     * b4_0900_ai_ci DEFAULT '' COMMENT '菜单类型（M目录 C菜单 F按钮 A 接口api）',
     * `visible` char(1) DEFAULT '0' COMMENT '菜单状态（0显示 1隐藏）',
     *   `status` char(1) DEFAULT '0' COMMENT '菜单状态（0正常 1停用）',
     * @return dict data
     */
    @Override
    public List<SysDictData> getDictData(String dictType) {
        Map<String, Object> dict = new HashMap<>();
        dict.put("sys_menu_type",getMenuTypeList());
        dict.put("sys_menu_visible",getMenuVisibleTypeList());
        dict.put("sys_menu_status",getMenuStatusList());
        return (List<SysDictData>) dict.getOrDefault(dictType, new ArrayList<SysDictData>());
    }

    private List<SysDictData> getMenuStatusList(){
        List<SysDictData> list = new ArrayList<>();
        list.add(new SysDictData(7L,"正常","0","sys_menu_type","","success","0"));
        list.add(new SysDictData(8L,"停用","1","sys_menu_type","","danger","0"));
        return list;
    }
    private List<SysDictData> getMenuVisibleTypeList(){
        List<SysDictData> list = new ArrayList<>();
        list.add(new SysDictData(5L,"显示","0","sys_menu_type","","success","0"));
        list.add(new SysDictData(6L,"隐藏","1","sys_menu_type","","info","0"));
        return list;
    }

    private List<SysDictData> getMenuTypeList(){
        List<SysDictData> list = new ArrayList<>();
        list.add(new SysDictData(1L,"目录","M","sys_menu_type","","info","0"));
        list.add(new SysDictData(2L,"菜单","C","sys_menu_type","","primary","0"));
        list.add(new SysDictData(3L,"按钮","F","sys_menu_type","","success","0"));
        list.add(new SysDictData(4L,"api","A","sys_menu_type","","warn","0"));
        return list;
    }
}
